import unittest
import warnings

import requests


class Auto_SuperviseTest(unittest.TestCase):
    def setUp(self):
        warnings.simplefilter("ignore", ResourceWarning)
        print("-------------------")
        self.session = requests.session()
        data = {
            "name": "yunweizhuguan",
            "pwd": "123asd!@#$",
            "code": ""
        }
        self.session.post(url='http://172.16.55.125:50042/api/common/login', data=data)
        print("登录成功")

    def tearDown(self):
        print("-------------------")
        self.session.close()

    def test_superviseTest(self):
        ''' 督促检索框用例（选择未督促） true为已督促  false为未督促 待核查处置事件 '''
        response = self.session.get(url='http://172.16.55.125:50042/api/bpmn?url=%2Ftask%2Flist&start=2021-03-31+00:00:00&end=2022-03-31+23:59:59&status=2,4&superviseStatus=false&disposalPersonName=&eventKind=&eventType=&deptName=&deptId=&eventName=&timeLimit=&srcType=&username=14&isAsc=true&otherStatus=3,5,6,7&pageIndex=1&pageSize=10')
        result = response.json()
        for item in result['data']['list']:
            print('superviseStatus' in item)
            t = 'superviseStatus' in item
            if t is True:
                print(item['eventName'], item['superviseStatus'])
            self.assertFalse(t)

    def test_superviseTest1(self):
        ''' 督促检索框用例（选择未督促） true为已督促  false为未督促 已核查事件 '''
        response1 = self.session.get(url='http://172.16.55.125:50042/api/bpmn?url=%2Ftask%2Flist&start=2021-03-31+00:00:00&end=2022-03-31+23:59:59&status=3,5,6,7&superviseStatus=false&disposalPersonName=&eventKind=&eventType=&deptName=&deptId=&eventName=&timeLimit=&srcType=&username=14&isAsc=true&result=-1&state=-1&otherStatus=2,4&pageIndex=1&pageSize=10')
        result1 = response1.json()
        for item1 in result1['data']['list']:
            print('superviseStatus' in item1)
            t1 = 'superviseStatus' in item1
            if t1 is True:
                print(item1['eventName'], item1['superviseStatus'])
            self.assertFalse(t1)


if __name__ == "__main__":
    Auto_SuperviseTest()
